package TEST;

public class Test2 {
    public static void main(String[] args) {
        String s1 = "hello,world.txt";

        int index = s1.indexOf("lo");//获取字符或字符串的第一个位置
        System.out.println(index);
        int dex = s1.lastIndexOf(".txt");//获取字符或字符串的最后一个位置
        System.out.println(dex);
        String s = s1.substring(0,dex);//截取指定位置的字符串
        System.out.println(s);

        String s2 = " addf f sfg dgdg   ";
        System.out.println(s2.length());
        System.out.println(s2.trim().length());
        System.out.println(s2.trim());//去掉前后空格
    }
}
